/**
 * @param {number[]} rungs
 * @param {number} dist
 * @return {number}
 */
 var addRungs = function(rungs, dist) {
    let ans = 0
    let pos = 0
    for(let r of rungs){
        const dif = r - pos
        if(dif > dist){
            while(r-pos > dist){
                pos += dist
                ans += 1
            }
        }
        pos = r
    }
    return ans
};